package xhwl.insurance.http.api;

import com.google.gson.Gson;

import okhttp3.RequestBody;
import rx.Observable;
import xhwl.android.common.util.SPUtil;
import xhwl.insurance.http.ApiService;
import xhwl.retrofitrx.BaseApi;

/**
 * Created by admin on 2017/6/6.
 */

public class AddPatientApi extends BaseApi {

    AddPatientApiReq req;

    public AddPatientApi(String person_age, String person_birth, String person_idcard,
                         String person_mobile, String person_name, String person_sex) {
        req = new AddPatientApiReq(person_age, person_birth, person_idcard, person_mobile, person_name, person_sex);
    }

    @Override
    protected Observable getObservable() {
        RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(req));
        return retrofit.create(ApiService.class).addpatient(requestBody);
    }

    public class AddPatientApiReq {

        /**
         * member_id : 488502
         * person_age : 28
         * person_birth : 1989-03-26
         * person_idcard : 371327198903262827
         * person_mobile : 18810718149
         * person_name : 王兵
         * person_sex : 1
         */

        private String member_id;
        private String person_age;
        private String person_birth;
        private String person_idcard;
        private String person_mobile;
        private String person_name;
        private String person_sex;

        public AddPatientApiReq(String person_age, String person_birth, String person_idcard,
                                String person_mobile, String person_name, String person_sex) {
            this.member_id = SPUtil.getPersonInfoSp().getString(SPUtil.SPPersonInfo.MEMBER_ID, "");
            this.person_age = person_age;
            this.person_birth = person_birth;
            this.person_idcard = person_idcard;
            this.person_mobile = person_mobile;
            this.person_name = person_name;
            this.person_sex = person_sex;
        }
    }
}
